import { httpClient } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';
import { AjaxResult } from '@/api/model';
import { PageRequest, PageData } from '@/utils/common/types';
import { FileOutputDto } from './file.data';

enum Api {
  Read = '/api/admin/file/read',
  Delete = '/api/file/delete',
}

export function Read(request: PageRequest, mode: ErrorMessageMode = 'message') {
  return httpClient.post<PageData<FileOutputDto>>(
    {
      url: Api.Read,
      params: request,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function Delete(id: string, mode: ErrorMessageMode = 'message') {
  return httpClient.get<AjaxResult>(
    {
      url: Api.Delete,
      params: { id: id },
    },
    {
      errorMessageMode: mode,
    },
  );
}
